<?php
// Check-see if we have the config.fldb file, if not display an error. Becuase it should be there.
if(!file_exists(dirname(__FILE__)."/../conf.fldb")) { header("location: ".$_SERVER["REQUEST_URI"]."/../admin/errors/no_conf.html"); die(); }

// Have a gander for the posts.fldb file, if it's not there then display an error. Because it too should be there
if(!file_exists(dirname(__FILE__)."/../posts.fldb")) { header("location: ".$_SERVER["REQUEST_URI"]."/../admin/errors/no_posts.html"); die(); }

// Making a dangerous assumtion that the system has been downloaded properly, if it has then there should be the config.fldb file present. And if it's empty, then we should run setup.
if((file_get_contents(dirname(__FILE__)."/../conf.fldb") == "") && (!isset($_GET['setup']))) { header("location: ".$_SERVER["REQUEST_URI"]."/../admin/setup/index.php?setup&stage=1"); die(); }

// And if the config file IS present and has stuff in it, decode it and make it a huge global variable.
else {
	global $config;
	$config = unserialize(base64_decode(file_get_contents(dirname(__FILE__)."/../conf.fldb")));
}

// Make another dangerous assumption that the posts.fldb file exists, and see if it's empty
if((file_get_contents(dirname(__FILE__)."/../posts.fldb") != ""))

// And if it's got things in it, stick it into a large variable.
{
	global $glob_posts;
	$glob_posts = unserialize(base64_decode(file_get_contents(dirname(__FILE__)."/../posts.fldb")));
}

// The file of all the useful functions. Always nice to have.
require_once("functions.php");
?>